package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 工单
 * </p>
 *
 * @author linan
 * @date 2023-04-25
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "WorkOrderWorkOrderStatusEnum", description = "工单状态 #{ORDER_TO_BE_RECEIVED:待接单;PENDING:待处理;FINISH:已完成;REVOKE:已撤销;CANCEL:已作废-枚举")
public enum WorkOrderWorkOrderStatusEnum implements BaseEnum {

    /**
     * ORDER_TO_BE_RECEIVED="待接单"
     */
    ORDER_TO_BE_RECEIVED("待接单"),
    /**
     * PENDING="待处理"
     */
    PENDING("待处理"),
    /**
     * FINISH="已完成"
     */
    FINISH("已完成"),
    /**
     * REVOKE="已撤销"
     */
    REVOKE("已撤销"),
    /**
     * CANCEL="已作废"
     */
    CANCEL("已作废"),
    /**
     * RETURN="已退回"
     */
    RETURN("已退回"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static WorkOrderWorkOrderStatusEnum match(String val, WorkOrderWorkOrderStatusEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static WorkOrderWorkOrderStatusEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(WorkOrderWorkOrderStatusEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "ORDER_TO_BE_RECEIVED,PENDING,FINISH,REVOKE,CANCEL,RETURN", example = "ORDER_TO_BE_RECEIVED")
    public String getCode() {
        return this.name();
    }

}
